
import { defineStore } from 'pinia'
import { requestUserInfo, requestUpdateUserInfo } from './my-info.api'

export default defineStore('myInfo', {
    state: () => {
        return {
            
        }
    },
    getters: {
    },
    actions: {
        // 获取用户信息
        getUserInfo() {
            return new Promise((resolve, reject) => {
                requestUserInfo().then(response => {
                    const res: any = response.data
                    if (res.code === 200) {
                        resolve(res.data)
                    }
                })
            })
        },
        // 更新用户信息
        updateUserInfo(formData: any, poemsListInfo: any) {
            return new Promise((resolve, reject) => {
                requestUpdateUserInfo(formData, poemsListInfo).then(response => {
                    const res: any = response.data
                    if (res.code === 200) {
                        resolve(res.data)
                    }
                })
            })
        },
    }
})
